<?php
/**
 * Created by PhpStorm.
 * User: qishengqiang
 * Date: 2021-02-04
 * Time: 16:19
 */

namespace app\admin\controller;


use app\admin\BaseController;

class ConfigController extends BaseController
{
    /**
     * @return \think\response\Json
     */
    public function indexAction()
    {
        $configs = $this->app->configService->getLists();

        return json(['code' => 200, 'msg' => '查询成功', 'data'=> $configs]);
    }

    /**
     * @param $id
     * @return \think\response\Json
     */
    public function updateAction()
    {
        try {
            $this->app->configService->update($this->post['configs']);

            return json(['code' => 200, 'msg' => '操作成功', 'data'=> []]);
        } catch (\Exception $e) {
            return json(['code' => $e->getCode(), 'msg' => $e->getMessage(), 'data'=> []]);
        }
    }
}